home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-17 | 4.2 KB | 259 lines | [TEXT/CWIE] |
- // DReminder.cp -- data container class for AMReminder
-
- #include "AMEngine.h"
- #include "PString.h"
- #include "DReminder.h"
-
- #include <DateTimeUtils.h>
-
- //----------
- DReminder::DReminder ()
- {
- mDateTime.od.eraAlt = 0;
- ::GetTime (&mDateTime.od.oldDate);
- AssignPStr (mMessage, "\p");
- mShowAlert = false;
- mShowIcon = false;
- mPlaySound = false;
- mSoundIndex = 1;
- }
-
- //----------
- DReminder::~DReminder ()
- {
- }
-
- //----------
- void DReminder::CopyFrom (
- const DReminder& inOther)
- {
- mDateTime = inOther.mDateTime;
- AssignPStr (mMessage, inOther.mMessage);
- mShowAlert = inOther.mShowAlert;
- mShowIcon = inOther.mShowIcon;
- mPlaySound = inOther.mPlaySound;
- mSoundIndex = inOther.mSoundIndex;
- }
-
- //----------
- void DReminder::ReadFromFile (
- AMEngine* engine)
- {
- engine->ReadBytes (&mDateTime, sizeof (mDateTime));
- engine->ReadPString (mMessage);
- engine->ReadBytes (&mShowAlert, sizeof (mShowAlert));
- engine->ReadBytes (&mShowIcon, sizeof (mShowIcon));
- engine->ReadBytes (&mPlaySound, sizeof (mPlaySound));
- engine->ReadBytes (&mSoundIndex, sizeof (mSoundIndex));
- }
-
- //----------
- void DReminder::WriteToFile (
- AMEngine* engine)
- {
- engine->WriteBytes (&mDateTime, sizeof (mDateTime));
- engine->WritePString (mMessage);
- engine->WriteBytes (&mShowAlert, sizeof (mShowAlert));
- engine->WriteBytes (&mShowIcon, sizeof (mShowIcon));
- engine->WriteBytes (&mPlaySound, sizeof (mPlaySound));
- engine->WriteBytes (&mSoundIndex, sizeof (mSoundIndex));
- }
-
-
- //----------
- LongDateRec DReminder::GetDateTime () const
- {
-
- return mDateTime;
- }
-
- //----------
- void DReminder::SetDateTime (
- LongDateRec inValue)
- {
- mDateTime = inValue;
-
- SignalDataChanged (idDateTime);
- }
-
-
- //----------
- StringPtr DReminder::GetMessage (
- Str255 outPtr) const
- {
-
- AssignPStr (outPtr, mMessage);
- return (StringPtr)mMessage;
- }
-
- //----------
- void DReminder::SetMessage (
- Str255 inValue)
- {
- AssignPStr (mMessage, inValue);
-
- SignalDataChanged (idMessage);
- }
-
- //----------
- void DReminder::SetMessage (
- CharsHandle inValue)
- {
- AssignPStr (mMessage, inValue);
-
- SignalDataChanged (idMessage);
- }
-
-
- //----------
- Boolean DReminder::GetShowAlert () const
- {
-
- return mShowAlert;
- }
-
- //----------
- void DReminder::SetShowAlert (
- Boolean inValue)
- {
- mShowAlert = inValue;
-
- SignalDataChanged (idShowAlert);
- }
-
-
- //----------
- Boolean DReminder::GetShowIcon () const
- {
-
- return mShowIcon;
- }
-
- //----------
- void DReminder::SetShowIcon (
- Boolean inValue)
- {
- mShowIcon = inValue;
-
- SignalDataChanged (idShowIcon);
- }
-
-
- //----------
- Boolean DReminder::GetPlaySound () const
- {
-
- return mPlaySound;
- }
-
- //----------
- void DReminder::SetPlaySound (
- Boolean inValue)
- {
- mPlaySound = inValue;
-
- SignalDataChanged (idPlaySound);
- }
-
-
- //----------
- SInt16 DReminder::GetSoundIndex () const
- {
-
- return mSoundIndex;
- }
-
- //----------
- void DReminder::SetSoundIndex (
- SInt16 inValue)
- {
- mSoundIndex = inValue;
-
- SignalDataChanged (idSoundIndex);
- }
-
-
- //----------
- StringPtr DReminder::GetDateString (
- Str255 outPtr) const
- {
- LongDateTime longSeconds;
- static Str255 dateString;
-
- LongDateToSeconds (&mDateTime, &longSeconds);
- LongDateString (&longSeconds, shortDate, dateString, nil);
-
- return dateString;
-
- }
-
- //----------
- void DReminder::SetDateString (
- Str255 inValue)
- {
-
- SignalDataChanged (idDateString);
- }
-
-
- //----------
- StringPtr DReminder::GetTimeString (
- Str255 outPtr) const
- {
- LongDateTime longSeconds;
- static Str255 timeString;
-
- LongDateToSeconds (&mDateTime, &longSeconds);
- LongTimeString (&longSeconds, false, timeString, nil);
-
- return timeString;
-
- }
-
- //----------
- void DReminder::SetTimeString (
- Str255 inValue)
- {
-
- SignalDataChanged (idTimeString);
- }
-
-
- //----------
- LongDateRec DReminder::GetYearMonthDay () const
- {
- return mDateTime;
-
- }
-
- //----------
- void DReminder::SetYearMonthDay (
- LongDateRec inValue)
- {
- mDateTime.ld.year = inValue.ld.year;
- mDateTime.ld.month = inValue.ld.month;
- mDateTime.ld.day = inValue.ld.day;
- SignalDataChanged (idDateTime);
-
- SignalDataChanged (idYearMonthDay);
- }
-
-
- //----------
- LongDateRec DReminder::GetHourMinute () const
- {
- return mDateTime;
-
- }
-
- //----------
- void DReminder::SetHourMinute (
- LongDateRec inValue)
- {
- mDateTime.ld.hour = inValue.ld.hour;
- mDateTime.ld.minute = inValue.ld.minute;
- SignalDataChanged (idDateTime);
-
- SignalDataChanged (idHourMinute);
- }
-